package com.example.zhaohang.utils;

import android.os.Handler;
import android.os.Looper;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * 作者： itheima
 * 时间：2016-12-01 17:00
 *
 */


//主子线程切换工具类
public class ThreadUtils {


    private static Handler sHandler = new Handler(Looper.getMainLooper());


    //这是线程池切换主子线程用
    private static Executor sExecutor = Executors.newSingleThreadExecutor();


    public static void runOnSubThread(Runnable runnable){
        sExecutor.execute(runnable);
    }


    public static void runOnUIThread(Runnable runnable){
        sHandler.post(runnable);
    }
}
